const GameModle = require('../models/GameModel');
const NewModel = require('../models/NewModel');

const GameService = {
    registered: (id, winTime, enemyId) => {
        return GameModle.create({
            id, winTime, enemyId
        })
    },
    idFindGameData: (id) => {
        return GameModle.find({
            id
        })
    },
    idGetWinTime: (id) => {
        return GameModle.find({
            id
        }, ["winTime"])
    },
    winTimeUp: async (id) => {
        console.log(id);
        const result = await GameModle.find({ id }, ["winTime"])
        console.log(result[0].winTime);
        return GameModle.updateOne(
            { id },
            { winTime: result[0].winTime + 1 }
        );
    }
}


module.exports = GameService